﻿using System;
using WickedFlame.Core.Shapes;

namespace WickedFlame.Core.State
{
    [Serializable]
    internal class EllipseMemento : ShapeMemento
    {
        double x;
        double y;
        double width;
        double height;

        public override void SaveProperties(VectorShape shape)
        {
            base.SaveProperties(shape);

            var r = shape as EllipseShape;
            if (r != null)
            {
                x = r.X;
                y = r.Y;
                width = r.Width;
                height = r.Height;
            }
        }

        public override void ResetProperties(VectorShape shape)
        {
            base.ResetProperties(shape);

            var r = shape as EllipseShape;
            if (r != null)
            {
                r.X = x;
                r.Y = y;
                r.Width = width;
                r.Height = height;
            }
        }

        public override VectorShape GenerateShape()
        {
            var shape = new EllipseShape();
            shape.ResetState(this);

            return shape;
        }
    }
}
